import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
const routes = [
  {
    path: "/",
    redirect: "/login"
  },
  // 登录
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/login.vue')
  },
  // 用户
  {
    path: '/user',
    name: 'user',
    component: () => import('../views/user.vue'),
    redirect: "/user/user_students",
    children: [
      {
        path: 'user_students',
        name: 'Student',
        component: () => import('../views/user/Student.vue'),
        meta: {
          title: [
            "用户",
            '学员管理'
          ]
        }
      },
      {
        path: 'user_teachers',
        name: 'Teacher',
        component: () => import('../views/user/Teacher.vue'),
        meta: {
          title: [
            "用户",
            '讲师管理'
          ]
        }
      },
      {
        path: 'user_assistteacher',
        name: 'AssistTeacher',
        component: () => import('../views/user/AssistTeacher.vue'),
        meta: {
          title: [
            "用户",
            '助教管理'
          ]
        }
      },
      // 教学
      {
        path: 'teach/course/manage',
        name: 'TeachCourseManage',
        component: () => import('../views/teach/course/Manage.vue'),
        meta: {
          title: [
            "教学",
            "课程管理",
            '课程管理'
          ]
        }
      },
      {
        path: 'teach/course/catagory',
        name: 'TeachCourseCatagory',
        component: () => import('../views/teach/course/Catagory.vue'),
        meta: {
          title: [
            "教学",
            "课程管理",
            '课程分类'
          ]
        }
      },
      // 题库
      {
        path: 'questionc/uestioncheckpoint/manage',
        name: 'QuestionQuestionCheckPointManage',
        component: () => import('../views/tiku/kao.vue'),
        meta: {
          title: [
            "题库",
            '题库管理',
            "考点管理"
          ]
        }
      },
      {
        path: 'question/questionbank/kaodian_edit',
        name: 'QuestionQuestionBankKaodian_edit',
        component: () => import('../views/tiku/xiang.vue'),
        meta: {
          title: [
            "题库",
            '题库管理',
            "考点管理",
            "编辑考点"

          ]
        }
      },
      {
        path: 'question/questionbank/manag',
        name: 'QuestionQuestionBankManage',
        component: () => import('../views/tiku/ku.vue'),
        meta: {
          title: [
            "题库",
            '题库管理',
            "题库管理"
          ]
        }
      }, {
        path: 'question/questionbank/catagory',
        name: 'QuestionQuestionBankCatagory',
        component: () => import('../views/tiku/fen.vue'),
        meta: {
          title: [
            "题库",
            '题库管理',
            "题库分类"
          ]
        }
      }, {
        path: 'question/question/topicError',
        name: 'QuestionQuestionTopicError',
        component: () => import('../views/tiku/bao.vue'),
        meta: {
          title: [
            "题库",
            '题库管理',
            "题目报错"
          ]
        }
      },
      // 运营   下面的网站营运
      {
        path: 'Operation/Banner',
        name: 'OperationBanner',
        component: () => import('../views/yun/pei.vue'),
        meta: {
          title: [
            "运营",
            'banner配置',
          ]
        }
      },
      {
        path: 'Operation/MobileRecomment',
        name: 'OperationMobileRecomment',
        component: () => import('../views/yun/home.vue'),
        meta: {
          title: [
            "运营",
            '首页配置',
          ]
        }
      },
      {
        path: 'Operation/MobileSetting',
        name: 'OperationMobileSetting',
        component: () => import('../views/yun/yi.vue'),
        meta: {
          title: [
            "运营",
            '移动端设置',
          ]
        }
      },
      {
        path: 'Operation/MobileShare',
        name: 'OperationMobileShare',
        component: () => import('../views/yun/fen.vue'),
        meta: {
          title: [
            "运营",
            '分享模板',
          ]
        }
      },
      // 营销
      {
        path: 'market/groupBooking/manage',
        name: 'MarketGroupBookingManage',
        component: () => import('../views/ying/duo.vue'),
        meta: {
          title: [
            "营销",
            '多人拼团',
            "多人拼团"
          ]
        }
      }, {
        path: 'market/groupBooking/edit',
        name: 'MarketGroupBookingEdit',
        component: () => import('../views/ying/xin.vue'),
        meta: {
          title: [
            "营销",
            '新建',
            "编辑拼团"
          ]
        }
      }
    ],
  }
]
const router = new VueRouter({
  routes
})
router.beforeEach((to, from, next) => {
  if (localStorage.getItem("token")) {
    next();
  } else {
    if (to.path == "/login") {
      next();
    } else {
      next("/login")
    }
  }
})
export default router